package com.ruoyi.hr.controller.hr.entryexitmanage.blacklistmanage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.entryexitmanage.blacklistmanage.BlacklistManageService;
import com.ruoyi.hr.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @author zeo
 * @explain 黑名单
 * @date 2020/4/15
 */
@Controller
@RequestMapping("/entryManage/BlackListManage")
public class BlacklistManageController extends BaseController {

    @Autowired
    BlacklistManageService blacklistManageService;

    @Autowired
    AuthorityService authorityService;

    private String prefix = "hr/entryexitmanage/blacklistmanage";

    @GetMapping()
    public String BlackListManage() {
        return prefix + "/blacklistManage";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        startPage();
        return getDataTable(blacklistManageService.list(map));
    }

    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    @RequestMapping("/findEmpList")
    @ResponseBody
    public TableDataInfo findEmpList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(blacklistManageService.findEmpList(map, authority));
    }

    @RequestMapping("/add")
    @ResponseBody
    public BaseResult add(String allEid) {
        return blacklistManageService.add(allEid);
    }

    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        mmap.put("data",blacklistManageService.findData(id));
        return prefix + "/edit";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestParam Map map) {
        return toAjax(blacklistManageService.edit(map));
    }

    @RequestMapping("/procedure")
    @ResponseBody
    public BaseResult procedure(String allId,String procedure) {
        return blacklistManageService.procedure(allId,procedure);
    }

    @GetMapping("/listHistory")
    public String listHistory() {
        return prefix + "/blacklistManageHistory";
    }

    @RequestMapping("/listHistory")
    @ResponseBody
    public TableDataInfo listHistory(@RequestParam Map map) {
        return getDataTable(blacklistManageService.listHistory(map));
    }
}
